//
//  addViewController.m
//  AddressBook
//
//  Created by 苗钧豪 on 16/8/5.
//  Copyright © 2016年 苗钧豪. All rights reserved.
//

#import "addViewController.h"
#import "Friends.h"
#import "mainTableViewController.h"

@interface addViewController ()
@property(nonatomic,strong)Friends *friends;
@end

@implementation addViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    
}
- (IBAction)DoneAction:(id)sender {
    NSArray *array = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
    NSString *filePath = [[array firstObject] stringByAppendingPathComponent:@"friends"];
    UIImage *image = [UIImage imageNamed:@"1"];
    _friends = [Friends new];
    _friends.Name = _nameF.text;
    _friends.Phone = _phoneF.text;
    _friends.City = _cityF.text;
    _friends.imgData = UIImagePNGRepresentation(image);
    [NSKeyedArchiver archiveRootObject:_friends toFile:filePath];
//    mainTableViewController *vc = [[mainTableViewController alloc]init];
    mainTableViewController *vc =  [self.navigationController.viewControllers firstObject];
    [vc.Arr addObject:_friends];
    [self.navigationController popViewControllerAnimated:YES];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
